<script setup lang="ts">

import IndexHeader from "@/components/index/search/IndexHeader.vue";
import TeacherRecommend from "@/components/index/teacher/TeacherRecommend.vue";
import SelectedArticles from "@/components/index/article/SelectedArticles.vue";
import FooterBar from "@/components/index/footer/FooterBar.vue";

//主页文章请求
import {ref} from "vue";
import {articleContent,} from "@/http/home";

// 文章列表请求
let articleList = ref<any[]>([])
articleContent({pageNum: 1, pageSize: 5}).then(res => {
    // console.log(res)
    if (res.code === 200) {
        articleList.value = res.rows
    }

});

import {useRouter} from "vue-router";

//跳转到文章详情页面传参
const detailId=useRouter()
function jumpDetail(item) {
    detailId.push({
        path: '/textDetail',
        query: {id:item.id}
    })
}

// list传给子组件



</script>

<template>
    <div>
        <index-header></index-header>
        <!--    名师推荐-->
        <teacher-recommend></teacher-recommend>
        <!--        精选文章-->
        <van-cell-group inset>
            <van-cell title="精选文章" value="更多" is-link to="/allText"
                      style="font-size: 18px;background-color: #F5F5F5;padding-left: 0;padding-right: 0"/>
        </van-cell-group>
        <selected-articles v-for="item in articleList" :key="item.id" :articleInfo="item"  @click="jumpDetail(item)"></selected-articles>
        <footer-bar></footer-bar>
    </div>
</template>

<style scoped lang="less">

</style>